<template>
  <view class="index-container">
    <!-- 当前总积分卡片 -->
    <view class="total-points-card">
      <view class="points-label">当前总积分</view>
      <view class="points-value">{{ totalPoints }}</view>
    </view>

    <!-- 个人基础积分 -->
    <view class="basic-points-section">
      <view class="section-title">个人基础积分</view>
      <view class="points-list">
        <view 
          class="points-item" 
          v-for="item in basicPointsItems" 
          :key="item.key"
        >
          <text class="item-label">{{ item.label }}</text>
          <text class="item-points positive">{{ item.points }}</text>
        </view>
      </view>
    </view>

    <!-- 积分变动明细 -->
    <view class="points-details-section">
      <view class="section-title">积分变动明细</view>
      <view class="details-list">
                 <view 
           class="detail-item" 
           v-for="item in pointsChangeItems" 
           :key="item.id"
         >
           <view class="detail-left">
             <text class="change-points" :class="item.type">{{ item.points }}</text>
             <text class="change-date">{{ item.date }}</text>
           </view>
           <view class="detail-right">
             <text class="change-description">{{ item.description }}</text>
           </view>
         </view>
      </view>
    </view>
  </view>
</template>

<script lang="ts" setup>
import { ref } from 'vue'

// 当前总积分
const totalPoints = ref('3,280')

// 个人基础积分
const basicPointsItems = ref([
  {
    key: 'onboarding',
    label: '入职积分',
    points: '+1000'
  },
  {
    key: 'title',
    label: '职称积分',
    points: '+500'
  },
  {
    key: 'education',
    label: '学历积分',
    points: '+800'
  }
])

// 积分变动明细
const pointsChangeItems = ref([
  {
    id: 1,
    points: '+200',
    type: 'positive',
    description: '优秀员工表彰大会获奖',
    date: '2025-07-30'
  },
  {
    id: 2,
    points: '+150',
    type: 'positive',
    description: '季度销售目标达成奖励',
    date: '2025-07-25'
  },
  {
    id: 3,
    points: '-50',
    type: 'negative',
    description: '迟到扣分',
    date: '2025-07-20'
  },
  {
    id: 4,
    points: '+180',
    type: 'positive',
    description: '创新提案被采纳奖励',
    date: '2025-07-15'
  }
])
</script>

<style lang="scss" scoped>
.index-container {
  height: calc(100vh - 100rpx);
  background-color: #f5f5f5;
  padding: 30rpx;
  box-sizing: border-box;
  overflow-y: auto;
  padding-bottom: 120rpx;
}

.total-points-card {
  background: linear-gradient(135deg, #4095E5, #0e375e);
  border-radius: 16rpx;
  padding: 40rpx 30rpx;
  margin-bottom: 30rpx;
  text-align: center;
  box-shadow: 0 4rpx 16rpx rgba(64, 149, 229, 0.3);
}

.points-label {
  font-size: 28rpx;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 20rpx;
}

.points-value {
  font-size: 72rpx;
  font-weight: bold;
  color: #fff;
  line-height: 1;
}

.basic-points-section {
  background: #fff;
  border-radius: 16rpx;
  padding: 30rpx;
  margin-bottom: 30rpx;
  box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
}

.section-title {
  font-size: 32rpx;
  font-weight: bold;
  color: #333;
  margin-bottom: 30rpx;
}

.points-list {
  display: flex;
  flex-direction: column;
  gap: 20rpx;
}

.points-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20rpx 0;
  border-bottom: 1rpx solid #f0f0f0;
}

.points-item:last-child {
  border-bottom: none;
}

.item-label {
  font-size: 28rpx;
  color: #666;
}

.item-points {
  font-size: 28rpx;
  font-weight: 500;
}

.item-points.positive {
  color: #333;
}

.points-details-section {
  background: #fff;
  border-radius: 16rpx;
  padding: 30rpx;
  margin-bottom: 100rpx;
  box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
}

.details-list {
  display: flex;
  flex-direction: column;
  gap: 20rpx;
}

.detail-item {
  padding: 20rpx 0;
  border-bottom: 1rpx solid #f0f0f0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.detail-item:last-child {
  border-bottom: none;
}

.detail-left {
  display: flex;
  flex-direction: column;
  gap: 8rpx;
}

.detail-right {
  flex: 1;
  text-align: right;
}

.change-points {
  font-size: 32rpx;
  font-weight: bold;
}

.change-points.positive {
  color: #4CAF50;
}

.change-points.negative {
  color: #f44336;
}

.change-date {
  font-size: 24rpx;
  color: #999;
}

.change-description {
  font-size: 26rpx;
  color: #333;
  line-height: 1.4;
}
</style>
